package com.diploma.interaction.controller;

import com.alibaba.fastjson.JSON;
import com.diploma.interaction.model.User;
import com.diploma.interaction.model.WxxcxHdxx;
import com.diploma.interaction.service.HdxxService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping(value = "/v1/hdxx")
@Slf4j
public class HdxxController {

    @Autowired
    HdxxService hdxxService;

    @ApiOperation(value = "创建互动消息")
    @ApiImplicitParams(@ApiImplicitParam(paramType="body",dataType = "WxxcxHdxx",name="hdxx",value="插入的值"))
    @PostMapping(value = "createInternativeMessage",produces = "application/json")
    public void createInternativeMessage(@RequestBody WxxcxHdxx hdxx){
        log.info("日志要这么写,hdxx={}", JSON.toJSONString(hdxx));
        hdxxService.insertSelective(hdxx);
    }

    @PostMapping(value = "setInternativeMessage",produces = "application/json")
    public void setInternativeMessage(@RequestBody WxxcxHdxx hdxx){
        log.info("日志要这么写,hdxx={}", JSON.toJSONString(hdxx));
        hdxxService.updateByIdSelective(hdxx,hdxx.getXxxh().intValue());
    }

    @PostMapping(value = "getInternativeMessageList",produces = "application/json")
    public List<WxxcxHdxx> getInternativeMessageList(@RequestBody String staffId){
        log.info("日志要这么写,staffId={}", JSON.toJSONString(staffId));
        return hdxxService.selectByStaffId(staffId);
    }

    @PostMapping(value = "getUserInternativeMessageList",produces = "application/json")
    public List<WxxcxHdxx> getUserInternativeMessageList(@RequestBody User user){
        log.info("日志要这么写,user={}", JSON.toJSONString(user));
        return hdxxService.selectByUser(user);
    }

    @PostMapping(value = "deleteHdxx",produces = "application/json")
    public void deleteBdxx(@RequestBody int xxxh){
        log.info("日志要这么写,tel={}", JSON.toJSONString(xxxh));
        hdxxService.deleteById(xxxh);
    }
}
